﻿using System;
using System.Collections.Generic;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Miris.HumanMilkAnalyser.DataModel;

namespace Miris.HumanMilkAnalyser.Repository.EntityFramework.Mapping
{
    public class AnalysisItemMap : EntityTypeConfiguration<AnalysisItem>
    {
        public AnalysisItemMap()
        {
            // Primary Key
            this.HasKey(t => t.ItemName);

            // Properties
            this.Property(t => t.ItemName)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.ItemTitle)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.ItemUsage)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.DietaryRecommendation)
                .IsRequired()
                .HasMaxLength(100);

            // Table & Column Mappings
            this.ToTable("AnalysisItem");
            this.Property(t => t.ItemName).HasColumnName("ItemName");
            this.Property(t => t.ItemTitle).HasColumnName("ItemTitle");
            this.Property(t => t.ItemUsage).HasColumnName("ItemUsage");
            this.Property(t => t.DietaryRecommendation).HasColumnName("DietaryRecommendation");
        }
    }
}
